public class num1221 {
    //分割平衡字符串
    public int balancedStringSplit(String s) {
        if(s.length() == 0) {
            return 0;
        }
        int temp = 0;
        int balance = 0;
        for(int i = 0; i < s.length(); i ++) {
            if(s.charAt(i) == 'R') {
                temp ++;
            }
            if(s.charAt(i) == 'L') {
                temp --;
            }
            if(temp == 0) {
                balance ++;
            }
        }
        return balance;
    }
}
